<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>将 obejct 对象中属性是空字符串的替换为 null</title>
</head>

<body>
  <script>
    let obj = {
      a: 1,
      b: '',
    }
    console.log(obj, '修改之前的obj')
    let itemList = JSON.stringify(obj)
    let result = itemList.replace(/""/g, "null");
    obj = JSON.parse(result)
    console.log(obj, '修改之后的obj')
  </script>
</body>

</html>